//
//  PosApplyViewController.m
//  NewPro
//
//  Created by RYX on 2018/11/1.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "PosApplyViewController.h"
#import "OldPosApplyViewController.h"
#import "NewPosApplyViewController.h"
#import "SMPagerTabView.h"
#import "PosDetailViewController.h"

@interface PosApplyViewController ()<SMPagerTabViewDelegate,OldPosApplyViewControllerDelegate,NewPosApplyViewControllerDelegate>

@property (nonatomic, strong) NSMutableArray *vcArr;
@property (nonatomic, strong) SMPagerTabView *segmentView;
@property (nonatomic, strong) ViewHeader *header;

@end

@implementation PosApplyViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavBarWithTitle:@"机具申领"];
    
    [self setUI];
}

- (void)setUI{
    
    _vcArr = [NSMutableArray array];
    
    OldPosApplyViewController *vc1 = [[OldPosApplyViewController alloc] init];
    vc1.delegate = self;
    vc1.title = @"传统POS";
    
    NewPosApplyViewController *vc2 = [[NewPosApplyViewController alloc]initWithNibName:nil bundle:nil];
    vc2.delegate = self;
    vc2.title = @"物料";

    [_vcArr addObject:vc1];
    [_vcArr addObject:vc2];
   
    self.segmentView.delegate = self;
    
    //可自定义背景色和tab button的文字颜色等
    //开始构建UI
    [_segmentView buildUI];
    
    //起始选择一个tab
    [_segmentView selectTabWithIndex:0 animate:NO];
    
}

#pragma mark - DBPagerTabView Delegate
- (NSUInteger)numberOfPagers:(SMPagerTabView *)view {
    return [_vcArr count];
}
- (UIViewController *)pagerViewOfPagers:(SMPagerTabView *)view indexOfPagers:(NSUInteger)number {
    return _vcArr[number];
}

- (void)whenSelectOnPager:(NSUInteger)number {
    NSLog(@"页面 %lu",(unsigned long)number);
}

#pragma mark - setter/getter
- (SMPagerTabView *)segmentView {
    if (!_segmentView) {
        self.segmentView = [[SMPagerTabView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - (iPhoneX_Top))];
        [self.view addSubview:_segmentView];
        
    }
    return _segmentView;
}

#pragma mark - OldPosApplyViewControllerDelegate,NewPosApplyViewControllerDelegate
- (void)onCellWith:(NSInteger)type{
    PosDetailViewController *VC = [[PosDetailViewController alloc] init];
    VC.VCType = type;
    [self.navigationController pushViewController:VC animated:YES];
}

@end
